﻿using Framework.Data.test;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using System.Reflection;
using System.Collections;

namespace testcomsole
{
	class Program
	{
		static void Main(string[] args)
		{
			//DapperDataService.MySqlConnection();
			//var sb = new StringBuilder();
			//sb.Append("SELECT * FROM Teacher");

			//Console.WriteLine(sb);

			//var teachers = Select();
			//foreach (var item in teachers)
			//{
			//	Console.WriteLine(item.Name);
			//}

			//string sql = "insert into ";


			//DataService.Insert(sql,DapperService.MySqlConnection());
			AddressInfo mm = new AddressInfo();
			List<AddressInfo> list = new List<AddressInfo>();

			for (int i = 0; i < 5; i++)
			{
				list.Add(new AddressInfo()
				{
					Id = i,
					userName = "陈卧龙" + i,
					userTel = "1813707015*" + i,
					Addressdetail = "江苏省苏州市工业园区国际科技园" + i,
					isMoren = i
				});
			}
			GetClasss(list);



			Console.ReadKey();
		}
		//public static IList<Teachers> Select()
		//{
		//	using (IDbConnection conn = DapperService.MySqlConnection())
		//	{
		//		string sql = "select * from teachers";
		//		return conn.Query<Teachers>(sql).ToList();
		//	}
		//}


		public static void GetClasss<T>(T model)
		{

			foreach (var item in (IEnumerable)model)
			{
				Type t = item.GetType();
				PropertyInfo[] PropertyList = t.GetProperties();
				foreach (PropertyInfo abc in PropertyList)
				{
					string name = abc.Name;
					object value = abc.GetValue(item, null);
				}
			}

		}

		public static void GetClass<T>(T model)
		{
			Type t = model.GetType();
			PropertyInfo[] PropertyList = t.GetProperties();
			foreach (PropertyInfo item in PropertyList)
			{
				string name = item.Name;
				object value = item.GetValue(model, null);
			}
		}
	}
	public class AddressInfo
	{
		public int Id { get; set; }
		public string userName { get; set; }
		public string userTel { get; set; }
		public string Addressdetail { get; set; }
		public int isMoren { get; set; }

		public AddressInfo()
		{
			//Id = 1;
			//userName = "陈卧龙";
			//userTel = "1813707015*";
			//Addressdetail = "江苏省苏州市工业园区国际科技园";
			//isMoren = 1;

			

		}
	}
}
